package lesson.c4.sample;

public class Test {
	
	private int timestamp;
	
	private Group group;
	
	private Course course;
	
	public Test(Group grp, Course crs){
		this(grp, crs, (int)(System.currentTimeMillis()/1000));
	}
	
	public Test(Group grp, Course crs, int timestamp){
		this.timestamp = timestamp;
		group = grp;
		course = crs;
	}
	
	public void doTest(){
		Student[] students = group.getStudents();
		for(Student student: students){
			student.setScore(course, timestamp, (int)(Math.random()* 101));
		}
	}
	
	public int getAverageScore(){
		int sum = 0;
		for(Student student: group.getStudents()){
			sum += student.getScore(course, timestamp);
		}
		sum = sum/group.getStudents().length;
		return sum;
	}
	
	public int getStudentScore(String name){
		Student student = group.getStudentByName(name);
		if(student == null) return -1;
		return student.getScore(course, timestamp);
	}
	
	public int getMax(){
		return 0;
	}
}
